package club.hicode.daydayup.readball;

import cn.hutool.core.util.StrUtil;
import org.junit.Test;

/**
 * StrTest
 *
 * @author Liu Chunfu
 * @date 2018-08-07 下午2:18
 **/
public class StrTest {

    @Test
    public void test1() {
        String s = hostName("https://mp.weixin.qq.com/");
        System.out.println(s);
    }

    public static String hostName(String url) {
        int start = url.indexOf("//");
        int end = url.indexOf(":", start);
        if (end == -1) {
            url = url.substring(start + 2);
            return StrUtil.removeSuffix(url, "/");
        }
        return url.substring(start + 2, end);
    }
}
